﻿using System;

namespace Moon.Sql
{
    /// <summary>
    /// 实体类自增长属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public sealed class MoonIdentityAttribute : Attribute
    {
        public MoonIdentityAttribute() { }
    }

    /// <summary>
    /// 实体类主键属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public sealed class MoonKeyAttribute : Attribute
    {
        public MoonKeyAttribute() { }
    }

    /// <summary>
    /// 实体类数据库中列名属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public sealed class MoonColumnAttribute : Attribute
    {
        /// <summary>
        /// 列名
        /// </summary>
        public string Name { get; set; }
        public int? Size { get; set; }

        /// <summary>
        /// 列名
        /// </summary>
        /// <param name="name"></param>
        /// <param name="size"></param>
        public MoonColumnAttribute(string name, int size = 0) 
        { 
            this.Name = name; 
            if(size > 0) this.Size = size; 
        }
    }

    /// <summary>
    /// 实体类表名属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public sealed class MoonTableAttribute : Attribute
    {
        /// <summary>
        /// 表名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 表名
        /// </summary>
        /// <param name="name"></param>
        public MoonTableAttribute(string name) { this.Name = name; }
    }

    /// <summary>
    /// 实体类忽略属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public sealed class MoonIgnoredAttribute : Attribute
    {
        public MoonIgnoredAttribute() { }
    }

    /// <summary>
    /// oracle 序列
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public sealed class MoonSequenceAttribute : Attribute
    {
        /// <summary>
        /// 序列名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 序列名称
        /// </summary>
        /// <param name="name"></param>
        public MoonSequenceAttribute(string name) { this.Name = name; }
    }
}
